home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / cron12.arc / CRON.DOC < prev    next >
Text File  |  1990-11-28  |  55KB  |  1,858 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                    CRON User's Guide
  27.  
  28.  
  29.                                Manual Revision 10-21-90
  30.                                    CRON Version 1.2
  31.  
  32.                                      Shareware by
  33.                                      Tron Hvaring
  34.                                       PO Box 371
  35.                                      N-8501 Narvik
  36.                                         Norway
  37.  
  38.                                   Phone: +47 82 44145
  39.                                   Fax: +47 82 44 160
  40.                                    BIXname: thvaring
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  66.  
  67.  
  68.  
  69.  
  70.         CRON User's Guide            Rev. 10-21-90                     Contents
  71.  
  72.  
  73.  
  74.                                    TABLE OF CONTENTS
  75.  
  76.  
  77.  
  78.      1    INTRODUCTION  . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  79.           1.1 Product Description   . . . . . . . . . . . . . . . . . . . .   1
  80.           1.2 Shareware   . . . . . . . . . . . . . . . . . . . . . . . . .   2
  81.           1.3 Acknowledgements  . . . . . . . . . . . . . . . . . . . . . .   2
  82.           1.4 System Requirements   . . . . . . . . . . . . . . . . . . . .   2
  83.           1.5 Feedback  . . . . . . . . . . . . . . . . . . . . . . . . . .   2
  84.  
  85.      2    INSTALLATION  . . . . . . . . . . . . . . . . . . . . . . . . . .   3
  86.           2.1 Archive Contents  . . . . . . . . . . . . . . . . . . . . . .   3
  87.           2.2 Installing CRON   . . . . . . . . . . . . . . . . . . . . . .   3
  88.           2.3 Setting up CRON's environment   . . . . . . . . . . . . . . .   3
  89.           2.4 Set Your Clock  . . . . . . . . . . . . . . . . . . . . . . .   4
  90.  
  91.      3    USING CRON  . . . . . . . . . . . . . . . . . . . . . . . . . . .   5
  92.           3.1 Command-line Summary  . . . . . . . . . . . . . . . . . . . .   5
  93.           3.2 Crontab override -- the '-c tab' option   . . . . . . . . . .   5
  94.           3.3 Disable logging -- the '-n' option  . . . . . . . . . . . . .   6
  95.           3.4 Swap Mode -- the '-s', '-d dir' and '-e' options  . . . . . .   6
  96.           3.5 Verbose mode -- the '-v' option   . . . . . . . . . . . . . .   6
  97.           3.6 Locking the logfile -- the '-L' option  . . . . . . . . . . .   7
  98.           3.7 Stopping CRON   . . . . . . . . . . . . . . . . . . . . . . .   7
  99.           3.8 Startup Information   . . . . . . . . . . . . . . . . . . . .   7
  100.  
  101.      4    THE CRONTAB IN DETAIL   . . . . . . . . . . . . . . . . . . . . .   8
  102.           4.1 Syntax Summary  . . . . . . . . . . . . . . . . . . . . . . .   8
  103.           4.2 The Date and Time fields  . . . . . . . . . . . . . . . . . .   8
  104.           4.3 The Command Field   . . . . . . . . . . . . . . . . . . . . .   9
  105.  
  106.      5    THE CRONLOG IN DETAIL   . . . . . . . . . . . . . . . . . . . . .  12
  107.           5.1 General Description   . . . . . . . . . . . . . . . . . . . .  12
  108.           5.2 Starting And Stopping CRON  . . . . . . . . . . . . . . . . .  12
  109.           5.3 Start and Stop of CRONTAB Entry Processing  . . . . . . . . .  13
  110.           5.4 Logging Multi-Command Execution   . . . . . . . . . . . . . .  14
  111.  
  112.      6    ERROR HANDLING  . . . . . . . . . . . . . . . . . . . . . . . . .  15
  113.           6.1 General Considerations  . . . . . . . . . . . . . . . . . . .  15
  114.           6.2 Failure to Spawn a Command  . . . . . . . . . . . . . . . . .  16
  115.           6.3 A Spawned Command Fails   . . . . . . . . . . . . . . . . . .  16
  116.           6.4 Other Internal CRON errors  . . . . . . . . . . . . . . . . .  17
  117.           6.5 Exit Codes and COMMAND.COM  . . . . . . . . . . . . . . . . .  17
  118.  
  119.      7    ADVANCED TOPICS   . . . . . . . . . . . . . . . . . . . . . . . .  18
  120.           7.1 Resource Requirements   . . . . . . . . . . . . . . . . . . .  18
  121.           7.2 Using CRON with DESQview  . . . . . . . . . . . . . . . . . .  18
  122.           7.3 CRON Technical Information  . . . . . . . . . . . . . . . . .  19
  123.           7.4 Differences between CRON and UNIX cron  . . . . . . . . . . .  19
  124.  
  125.      8    REFERENCE SECTION   . . . . . . . . . . . . . . . . . . . . . . .  21
  126.           8.1 Error Messages  . . . . . . . . . . . . . . . . . . . . . . .  21
  127.  
  128.  
  129.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  130.  
  131.  
  132.  
  133.  
  134.         CRON User's Guide            Rev. 10-21-90                     Contents
  135.  
  136.  
  137.           8.2 Exit Codes  . . . . . . . . . . . . . . . . . . . . . . . . .  22
  138.                8.2.1 Common Exit Codes  . . . . . . . . . . . . . . . . . .  22
  139.                8.2.2 Swap Mode  . . . . . . . . . . . . . . . . . . . . . .  23
  140.                8.2.3 Non-Swap Mode  . . . . . . . . . . . . . . . . . . . .  23
  141.                8.2.4 RC = -1 for '!' Commands   . . . . . . . . . . . . . .  23
  142.  
  143.      9    UTILITY PROGRAMS  . . . . . . . . . . . . . . . . . . . . . . . .  24
  144.           9.1 CDD.EXE   . . . . . . . . . . . . . . . . . . . . . . . . . .  24
  145.           9.2 LOGCHECK.EXE  . . . . . . . . . . . . . . . . . . . . . . . .  24
  146.  
  147.      10   PROGRAM HISTORY   . . . . . . . . . . . . . . . . . . . . . . . .  26
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  194.  
  195.  
  196.  
  197.  
  198.         CRON User's Guide            Rev. 10-21-90                       Page 1
  199.  
  200.  
  201.         1 INTRODUCTION
  202.  
  203.  
  204.  
  205.         1.1 Product Description
  206.  
  207.         This is version 1.2 of CRON.
  208.  
  209.         CRON is a timed command dispatcher that closely implements all the
  210.         features of the UNIX 'cron' utility that make sense in a DOS
  211.         environment.
  212.  
  213.         CRON reads a special file at startup, conventionally called CRONTAB,
  214.         where each entry defines a time and a command to execute at that time.
  215.         All commands are periodic, i.e. one-shot commands are not possible. The
  216.         longest period is one year, however, so this is not considered a
  217.         problem. In a PC environment, a command with a 1-year period is a one-
  218.         shot command for all practical purposes.
  219.  
  220.         After a command has executed, CRON re-calculates its next execution
  221.         time, then sorts the command list in time order and waits until the
  222.         first command in the list is due for execution. This sequence is
  223.         repeated undefinitely (or until the user stops CRON).
  224.  
  225.         CRON optionally logs its activites in a file conventionally called
  226.         CRONLOG. The layout of this file is more or less identical to the UNIX
  227.         cronlog and conveys the same information. The cronlog maintains an
  228.         accurate track of CRON's activities. A startup option is available to
  229.         make CRON lock the log file during access, allowing several
  230.         workstations on a network to run CRON with a central logfile on the
  231.         server.
  232.  
  233.         CRON works well with DESQview. Under DESQview, the background operation
  234.         of UNIX cron can be emulated by letting CRON run by itself in a (small)
  235.         window. Indeed, CRON was originally developed for use with DESQview.
  236.         See chapter 7 for instructions on using CRON with DESQview.
  237.  
  238.         Although based on UNIX cron, CRON is developed from scratch and
  239.         contains no proprietary code.
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  258.  
  259.  
  260.  
  261.  
  262.         CRON User's Guide            Rev. 10-21-90                       Page 2
  263.  
  264.  
  265.         1.2 Shareware
  266.  
  267.         CRON is shareware (aka. User Supported Software). This means that you
  268.         may freely use CRON for a reasonable evaluation period. You may also
  269.         freely distribute CRON11.ZIP in unmodified form, to BBS'es or
  270.         otherwise.
  271.  
  272.         If, after a reasonable evaluation period, you find CRON useful, I would
  273.         appreciate a contribution. NOK 150 (USD 25) suggested.
  274.  
  275.         All the usual disclaimers about damages, fitness for any particular
  276.         purpose and all that apply. In brief, you use CRON at your own risks
  277.         and perils.
  278.  
  279.         The contents of the CRON12.ZIP archive (i.e. CRON.EXE, CRONTAB,
  280.         CRON.DOC, LOGCHECK.EXE and CDD.EXE) are Copyright (C) 1990 by Tron
  281.         Hvaring.
  282.  
  283.  
  284.  
  285.         1.3 Acknowledgements
  286.  
  287.         Thanks to Thomas Wagner, Berlin, Germany for his EXEC routines (public
  288.         domain software, available as EXEC22.LZH on many BBS'es), on which
  289.         CRON's swap logic is based, and to Borland International for their
  290.         splendid debugger.
  291.  
  292.  
  293.  
  294.         1.4 System Requirements
  295.  
  296.         CRON runs on any IBM PC compatible computer under the DOS operating
  297.         system, version 3 or later. CRON requires a minimum of 44KB of free
  298.         memory to load, more for large CRONTABS.
  299.  
  300.  
  301.  
  302.         1.5 Feedback
  303.  
  304.         Your comments, suggestions and bug reports are most welcome. Since CRON
  305.         implements all the features of UNIX cron that make sense in a DOS
  306.         environment, new functionality is not likely to be added if not
  307.         sollicited by users. Bug reports, on the other hand, is a different
  308.         story.
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  322.  
  323.  
  324.  
  325.  
  326.         CRON User's Guide            Rev. 10-21-90                       Page 3
  327.  
  328.  
  329.         2 INSTALLATION
  330.  
  331.  
  332.  
  333.         2.1 Archive Contents
  334.  
  335.         This archive should contain the following files:
  336.  
  337.           -    CRON.EXE,      the executable program
  338.           -    CRON.DOC,      this document
  339.           -    CRONTAB,       annotated sample crontab
  340.           -    LOGCHECK.EXE,  let CRON control its log size
  341.           -    CDD.EXE        smarter CHDIR command
  342.  
  343.  
  344.  
  345.         2.2 Installing CRON
  346.  
  347.         Copy CRON.EXE to a directory in the DOS PATH (e.g. c:\bin).
  348.  
  349.         Create a directory for CRON's use, for example C:\CRON.
  350.  
  351.         This directory should be used for crontabs and log files.
  352.  
  353.         Create your crontab using the supplied CRONTAB as a template. Read the
  354.         rest of this document for more information about crontabs. Put your
  355.         crontab in the directory you created.
  356.  
  357.  
  358.  
  359.         2.3 Setting up CRON's environment
  360.  
  361.         CRON recognizes several environment variables. These are:
  362.  
  363.           CRONTAB   if set, CRON assumes it contains the name of a file that is
  364.                     to be used as the crontab. This can be overridden on the
  365.                     command line. Typically, this environment variable will
  366.                     contain C:\CRON\CRONTAB.
  367.  
  368.           CRONLOG   required if you want CRON to log its operations. Set to the
  369.                     name of the logfile (e.g. C:\CRON\CRONLOG). Note that
  370.                     CRONLOG must point to a fully qualified file name,
  371.                     including drive/path. This is required since the commands
  372.                     that CRON execute may change the logged drive and/or
  373.                     directory.
  374.  
  375.           TZ        indirectly consulted by the time management functions of
  376.                     the run-time library. If you live in a country that uses
  377.                     daylight savings, TZ must be set for CRON to operate
  378.                     correctly when the daylight savings period changes (twice a
  379.                     year). Syntax is:
  380.                          TZ=<time zone><hours after GMT><daylight saving>
  381.                     where <time zone> and <daylight saving> *must* be three-
  382.                     character upper-case strings, and <hours after GMT> is a
  383.  
  384.  
  385.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  386.  
  387.  
  388.  
  389.  
  390.         CRON User's Guide            Rev. 10-21-90                       Page 4
  391.  
  392.  
  393.                     signed number, positive westwards and negative eastwards
  394.                     relative to Greenwich. The actual contents of the character
  395.                     strings is irrelevant -- only their presence count. A
  396.                     correct value for Norway is
  397.                          TZ=CET-1CDT
  398.                     whereas a correct value for the UK is
  399.                          TZ=GMT0GDT
  400.                     If your country does not practice daylight saving, omit the
  401.                     last string, e.g. TZ=CET-1 if Norway hadn't practiced
  402.                     daylight saving.
  403.  
  404.           TMP       if CRON is run in swap mode, it will swap most of itself
  405.                     out of memory when executing commands. By default, CRON
  406.                     will swap to a temporary file in the directory named by the
  407.                     TMP variable, or in the current directory if the TMP
  408.                     directory does not exist. If you have a RAM disk with 50-
  409.                     70K of free space, set TMP to the name of directory on this
  410.                     RAM disk. The directory used for swapping can be overridden
  411.                     on the command line.
  412.  
  413.           COMSPEC   when CRON needs to spawn COMMAND.COM, it will use the name
  414.                     contained in this variable, which is normally
  415.                     C:\COMMAND.COM. Other shells, like 4DOS, can be used by
  416.                     setting COMSPEC appropriately.
  417.  
  418.  
  419.         Setting these environment variables allows you to start CRON with the
  420.         appropriate environment by simply typing CRON.
  421.  
  422.         Here's a selected part of my AUTOEXEC.BAT:
  423.  
  424.           SET CRONTAB=d:\cron\crontab
  425.           SET CRONLOG=d:\cron\cronlog
  426.           SET TMP=m:\tmp
  427.           SET TZ=CET-1CDT
  428.  
  429.  
  430.  
  431.         2.4 Set Your Clock
  432.  
  433.         CRON will not operate as expected if the DOS date and time are not set
  434.         correctly. In particular, remember to update your clock when crossing
  435.         daylight savings zone boundaries.
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  450.  
  451.  
  452.  
  453.  
  454.         CRON User's Guide            Rev. 10-21-90                       Page 5
  455.  
  456.  
  457.         3 USING CRON
  458.  
  459.  
  460.  
  461.         3.1 Command-line Summary
  462.  
  463.         CRON is started as follows:
  464.  
  465.           CRON [option] [option] ...
  466.  
  467.  
  468.         As a special case, entering "CRON ?" will display an option summary and
  469.         terminate.
  470.  
  471.         The available options are:
  472.  
  473.           -c tab    -- override CRONTAB name
  474.           -n        -- no log
  475.           -s        -- swap mode
  476.           -e        -- swap to LIM/EMS memory if possible
  477.           -d dir    -- swap directory override
  478.           -v        -- verbose mode
  479.           -L        -- lock CRONLOG during access if on network drive
  480.  
  481.  
  482.  
  483.         3.2 Crontab override -- the '-c tab' option
  484.  
  485.         This option overrides the name that CRON will use for the crontab.
  486.         'tab' must be the name of an existing file. Full drive/path syntax or
  487.         relative syntax may be used.
  488.  
  489.         In the absence of this option, CRON will look for the crontab as
  490.         follows:
  491.  
  492.           -    if the CRONTAB environment variable is set, use that name
  493.           -    otherwise, look in the directory that was current when CRON was
  494.                started for the file name "CRONTAB".
  495.  
  496.         CRON will complain and abort if it cannot find a crontab.
  497.  
  498.         Example (friday afternoon):
  499.  
  500.           cron -c d:\cron\weekend
  501.  
  502.         Note that CRON only reads the crontab at startup.
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  514.  
  515.  
  516.  
  517.  
  518.         CRON User's Guide            Rev. 10-21-90                       Page 6
  519.  
  520.  
  521.         3.3 Disable logging -- the '-n' option
  522.  
  523.         If CRON is set up for logging, this option disables logging. If CRON
  524.         would not have logged anyway the option is ignored.
  525.  
  526.         Logging is only done if the environment variable CRONLOG is set to a
  527.         fully qualified filename (i.e. with full drive/path syntax).
  528.  
  529.         CRON will complain if CRONLOG is set but does not point to a fully
  530.         qualified filename.
  531.  
  532.  
  533.  
  534.         3.4 Swap Mode -- the '-s', '-d dir' and '-e' options
  535.  
  536.         CRON may optionally swap most of itself out of memory when executing
  537.         other commands. This feature is enabled by entering the -s option.
  538.  
  539.         CRON will by default swap to a temporary file, either in the TMP
  540.         directory if set, or in the directory that was current when CRON was
  541.         started.
  542.  
  543.         The -e option will make CRON try to swap itself to LIM/EMS memory, if
  544.         present and available in sufficient quantities. See chapter 7 for a
  545.         discussion of memory requirements. If EMS swapping is not possible,
  546.         CRON reverts to disk swapping.
  547.  
  548.         The '-d dir' option will make CRON swap to a temporary file in the
  549.         directory 'dir' instead of the standard places described above.
  550.  
  551.         CRON complains if it sees -d or -e but not -s, and if 'dir' is not a
  552.         valid directory.
  553.  
  554.  
  555.  
  556.         3.5 Verbose mode -- the '-v' option
  557.  
  558.         This option requires that an ANSI driver be present in your system,
  559.         e.g. ANSI.SYS, or DVANSI.COM under DESQview.
  560.  
  561.         The effect of -v is that CRON maintains a real time display showing the
  562.         next command scheduled for execution, the time it will be executed, and
  563.         the time left (in seconds) until the command is executed.
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  578.  
  579.  
  580.  
  581.  
  582.         CRON User's Guide            Rev. 10-21-90                       Page 7
  583.  
  584.  
  585.         3.6 Locking the logfile -- the '-L' option
  586.  
  587.         If this option is entered, CRON will lock byte 0 of the logfile before
  588.         accessing it, using the DOS 3.1 locking calls.
  589.  
  590.         CRON uses the IOCTL Is Redirected Handle call to determine if the
  591.         logfile is on a network drive. Your DOS version must support this call
  592.         (DOS function 44H, subfunction 0AH) for logfile locking to work.
  593.  
  594.         Most networks support the DOS 3.1 locking calls. CRON has also been
  595.         tested and found to work fine on a Novell NetWare network.
  596.  
  597.         If your network does not support the way CRON goes about locking the
  598.         logfile, CRON will still work but will simply disable logfile locking.
  599.  
  600.  
  601.  
  602.         3.7 Stopping CRON
  603.  
  604.         CRON is stopped by typing ESC. CRON reminds you of this at startup.
  605.  
  606.  
  607.  
  608.         3.8 Startup Information
  609.  
  610.         When CRON starts, it will print a banner consisting of the program
  611.         name, version, copyright, memory available after CRON has processed the
  612.         crontab and grabbed what it needs, and a reminder that you should hit
  613.         ESC to stop CRON.
  614.  
  615.         If CRON believes that it runs under DESQview, it will print the
  616.         additional line '(DESQview detected)'.
  617.  
  618.         In verbose mode, CRON will then print information about the first
  619.         command to execute, and start its real-time second countdown.
  620.  
  621.         If this information looks funny (displaying left arrows and '['
  622.         characters) you don't have an ANSI driver resident. Put the line
  623.  
  624.           DEVICE=[drive:\path\]ANSI.SYS
  625.  
  626.         in your CONFIG.SYS file, or load DVANSI.COM before starting CRON if
  627.         running under DESQview.
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  642.  
  643.  
  644.  
  645.  
  646.         CRON User's Guide            Rev. 10-21-90                       Page 8
  647.  
  648.  
  649.         4 THE CRONTAB IN DETAIL
  650.  
  651.  
  652.  
  653.         4.1 Syntax Summary
  654.  
  655.         CRONTAB is a regular ASCII text file that can be created by any editor
  656.         or word processor in non-document mode.
  657.  
  658.         Lines containing a '#' character in column 1, and blank lines, are
  659.         ignored (useful for commenting crontabs).
  660.  
  661.         All other lines are interpreted as CRONTAB ENTRIES. A CRONTAB entry has
  662.         the following format:
  663.  
  664.         minute   hour   day   month   day-of-week   command
  665.  
  666.         Fields are separated by any number of tabs or spaces. No tabs or spaces
  667.         are allowed inside the first 5 fields. Maximum line length is 512
  668.         characters including the trailing CR/LF pair.
  669.  
  670.  
  671.  
  672.         4.2 The Date and Time fields
  673.  
  674.         These fields can have the following forms:
  675.  
  676.           *         all legal values
  677.           i,j,k     sequence of values
  678.           i-j       inclusive range of values
  679.  
  680.         The sequence and range forms may be combined, as in
  681.  
  682.           1,3,5,7-9,11,13-17,19
  683.  
  684.         An asterisk '*' overrides any other value in a field. Thus
  685.  
  686.           1,3,*,5,7
  687.  
  688.         is equivalent to
  689.  
  690.           *
  691.  
  692.         Legal ranges for the different fields are as follows:
  693.  
  694.           minute         -- 0..59
  695.           hour           -- 0..23 (24-hour clock)
  696.           day            -- 1..31 (must be consistent with month)
  697.           month          -- 1..12
  698.           day-of-week    -- 0..6, 0 = Sunday, 1 = Monday etc.
  699.  
  700.  
  701.         CRON detectes values that are out of range, and impossible dates (like
  702.         February 31.).
  703.  
  704.  
  705.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  706.  
  707.  
  708.  
  709.  
  710.         CRON User's Guide            Rev. 10-21-90                       Page 9
  711.  
  712.  
  713.  
  714.         The actual execution times computed by CRON is the largest matching set
  715.         of times. This is best explained by the following example:
  716.  
  717.           54 6 1,15 * 1 doreport
  718.  
  719.         means that the command 'doreport' will be executed at 06:54 on the 1.
  720.         and 15. of every month (month = '*'), AND on each monday (day-of-week =
  721.         1). If the 1. or 15. falls on a Monday, 'doreport' will not be executed
  722.         twice.
  723.  
  724.         The extremes in terms of periodicity are:
  725.  
  726.         * * * * * dooften     -- executes 'dooften' every minute
  727.         1 0 1 1 * calendar    -- executes 'calendar' at 00:01 each January 1.
  728.  
  729.  
  730.  
  731.         4.3 The Command Field
  732.  
  733.         The 'command' field of a CRONTAB entry consists of one or more COMMAND
  734.         LINES, separated by semicolons ';'. If the command field contains only
  735.         one command line, it should not be terminated by a semicolon.
  736.  
  737.         A COMMAND LINE obeys the following syntax:
  738.  
  739.           [~][!]DOS command line
  740.  
  741.         i.e. an optional '~' character, followed by an optional '!' character,
  742.         followed by a regular DOS command line.
  743.  
  744.         Thus a command field looks like
  745.  
  746.           [~][!]command line;[~][!]command line;[~][!]command line....
  747.  
  748.         or
  749.  
  750.           [~][!]command line
  751.  
  752.  
  753.         The '~' character means 'NOSWAP'. It means that CRON should not swap
  754.         itself out when executing this command, even if swapping is enabled. If
  755.         swapping is disabled, the character is ignored. This feature is useful
  756.         for small commands that require modest amounts of memory.
  757.  
  758.         If both '~' and '!' are entered, '~' must precede '!'.
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  770.  
  771.  
  772.  
  773.  
  774.         CRON User's Guide            Rev. 10-21-90                      Page 10
  775.  
  776.  
  777.         The '!' character is a synonym for %COMSPEC% /C, i.e. the contents of
  778.         the environment variable COMSPEC, followed by the string " /C ".
  779.  
  780.         Thus the command lines
  781.  
  782.           !dir
  783.  
  784.         and
  785.  
  786.           COMMAND /C dir
  787.  
  788.         are equivalent, provided COMSPEC points to COMMAND.COM.
  789.  
  790.         '!' (or its synonym) is *required* for COMMAND.COM internal commands,
  791.         like DIR, DEL and CD.
  792.  
  793.         '!' (or its synonym) is optional for executable programs, including
  794.         .BAT files.
  795.  
  796.         If your command uses redirection (i.e. <, >, >> or |), '!' is required
  797.         since redirection is handled by COMMAND.COM. Otherwise it should not be
  798.         used, as it adds no functionality except consuming a few K of
  799.         additional memory.
  800.  
  801.         Thus the command line
  802.  
  803.           sort <infile >outfile
  804.  
  805.         will not work as expected, but
  806.  
  807.           !sort <infile >outfile
  808.  
  809.         will.
  810.  
  811.         Note that CRON knows about .BAT files and will spawn COMMAND.COM
  812.         internally for them. Therefore, the '!' prefix is not needed for .BAT
  813.         files.
  814.  
  815.         When locating the command to execute, CRON follows the standard DOS
  816.         algorithm: first look in the current directory, then in each directory
  817.         along the PATH, respecting the search order for .COM, .EXE and .BAT
  818.         files. Thus CRONTAB command lines may be entered exactly as if you were
  819.         at the DOS prompt, except for the '!' prefix (which is implicit when at
  820.         the DOS command line).
  821.  
  822.         CRON sets the logged drive and directory to their startup values (i.e.
  823.         the drive and directory that were current when CRON started) before
  824.         executing a CRONTAB entry.
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  834.  
  835.  
  836.  
  837.  
  838.         CRON User's Guide            Rev. 10-21-90                      Page 11
  839.  
  840.  
  841.         If an entry contains multiple command lines, the logged drive and
  842.         directory are not reset between command lines. This allows entries such
  843.         as:
  844.  
  845.         57 5 1,15 * * ~!d:;~!cd \acct\dbase;misreport
  846.  
  847.         assuming that the program 'misreport' expects to be run from the
  848.         'D:\ACCT\DBASE' directory.
  849.  
  850.         The enclosed file CRONTAB contains several commented CRONTAB entries.
  851.  
  852.         See chapter 9 for a description of the enclosed utilities that are
  853.         useful in CRONTAB entries.
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  898.  
  899.  
  900.  
  901.  
  902.         CRON User's Guide            Rev. 10-21-90                      Page 12
  903.  
  904.  
  905.         5 THE CRONLOG IN DETAIL
  906.  
  907.  
  908.  
  909.         5.1 General Description
  910.  
  911.         The optional CRONLOG is a text file produced by CRON where all its
  912.         operations and their results are logged.
  913.  
  914.         CRONLOG is a plain ASCII text file with highly structured lines.
  915.         Cronlogs are suitable for automatic processing, for example with AWK or
  916.         similar utilities.
  917.  
  918.         The cronlog is always opened in APPEND mode, so it is ever-increasing.
  919.         The utility LOGCHECK.EXE (documented later) can be used to control the
  920.         size of the cronlog.
  921.  
  922.         CRON produces a log entry when:
  923.  
  924.           -    CRON is started
  925.           -    CRON is stopped
  926.           -    CRON starts to execute a CRONTAB entry
  927.           -    CRON has finished to execute a CRONTAB entry
  928.           -    CRON starts to execute subsequent command lines in a multi-
  929.                command entry
  930.           -    CRON has finished to execute a command line in a multi-command
  931.                entry.
  932.  
  933.         Entries have the following general format:
  934.  
  935.         <entry token> <operation> <date and time> <additional data>
  936.  
  937.  
  938.  
  939.         5.2 Starting And Stopping CRON
  940.  
  941.         These lines are as follows:
  942.  
  943.         !cron started at Fri Oct 19 13:22:35 1990
  944.         !cron stopped at Fri Oct 19 13:22:51 1990
  945.  
  946.         No further comments should be necessary.
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  962.  
  963.  
  964.  
  965.  
  966.         CRON User's Guide            Rev. 10-21-90                      Page 13
  967.  
  968.  
  969.         5.3 Start and Stop of CRONTAB Entry Processing
  970.  
  971.         When CRON starts executing a CRONTAB entry, it produces a log record
  972.         starting with the character '>'.
  973.  
  974.         A typical entry is as follows:
  975.  
  976.         > 'mapmem -v' Fri Oct 19 13:43:00 1990
  977.  
  978.         meaning that the command field 'mapmem -v' started to execute on the
  979.         indicated date and time.
  980.  
  981.  
  982.         When the command returns, CRON produces a log entry starting with the
  983.         '<' character, as follows:
  984.  
  985.         < 'mapmem -v' Fri Oct 19 13:43:00 1990, rc = 0
  986.  
  987.         meaning that the command 'mapmem -v' executed until the indicated date
  988.         and time (in this example, for less than 1 second), and returned with
  989.         an exit code 0 ('rc = 0').
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1026.  
  1027.  
  1028.  
  1029.  
  1030.         CRON User's Guide            Rev. 10-21-90                      Page 14
  1031.  
  1032.  
  1033.         5.4 Logging Multi-Command Execution
  1034.  
  1035.         For CRONTAB entries containing multiple command lines, CRON produces a
  1036.         sequence of records bracketed by a '>' entry, marking the start of the
  1037.         entry as a whole, and a '<' entry, marking the end of the entry as a
  1038.         whole. Between these entries, a pair or '>>' (start of command) and
  1039.         '<<' (end of command) is produced for each command line in the entry,
  1040.         including the first.
  1041.  
  1042.         The text of the '>' and '<' entries contain the entire command field.
  1043.         The text of the '>>' and '<<' entries contain the individual command
  1044.         lines, *without* any '!' or '~' prefix. These prefixes appear in the
  1045.         bracketing lines, though.
  1046.  
  1047.         A sample sequence is shown below, corresponding to the CRONTAB entry
  1048.  
  1049.           54 16 * * * !d:;!cd \cron;mapmem -v
  1050.  
  1051.         > '!d:;!cd \cron;mapmem -v' Fri Oct 19 16:54:00 1990
  1052.         >> 'd:' Fri Oct 19 16:54:00 1990
  1053.         << 'd:' Fri Oct 19 16:54:00 1990, rc = 0
  1054.         >> 'cd \cron' Fri Oct 19 16:54:00 1990
  1055.         << 'cd \cron' Fri Oct 19 16:54:00 1990, rc = 0
  1056.         >> 'mapmem -v' Fri Oct 19 16:54:00 1990
  1057.         << 'mapmem -v' Fri Oct 19 16:54:01 1990, rc = 0
  1058.         < '!d:;!cd \cron;mapmem -v' Fri Oct 19 16:54:01 1990, rc = 0
  1059.  
  1060.         Exit codes are only produced for '<' and '<<' entries. See the next
  1061.         chapter for a discussion of how to interpret these codes.
  1062.  
  1063.         Some '<' and '<<' entries may contain the string "*** FAILED ***". This
  1064.         means that an error occured. See the next chapter for an interpretation
  1065.         of such entries.
  1066.  
  1067.         In a bracket '<' line, the 'rc = n' field has the same value as the
  1068.         last sub-command that was executed.
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1090.  
  1091.  
  1092.  
  1093.  
  1094.         CRON User's Guide            Rev. 10-21-90                      Page 15
  1095.  
  1096.  
  1097.         6 ERROR HANDLING
  1098.  
  1099.  
  1100.  
  1101.         6.1 General Considerations
  1102.  
  1103.         Errors may occur for several reasons:
  1104.  
  1105.           -    CRON does not have enough resources to run
  1106.           -    CRON may be unable to locate or spawn a command
  1107.           -    a critical error can hit CRON (logfile disk full, swap error)
  1108.           -    the spawned command can fail
  1109.           -    a critical error can hit a spawned command
  1110.           -    a spawned command may encounter an internal exception requiring
  1111.                user intervention (i.e. the command prompts for keyboard input).
  1112.  
  1113.         If a critical error occurs -- either inside CRON or in a spawned
  1114.         command -- you are simply out of luck, since the infamous 'Abort,
  1115.         Retry, Ignore' requires user intervention (i.e. keyboard input).
  1116.  
  1117.         I considered trapping critical errors within CRON, but decided against
  1118.         it. Since CRON is typically run on an unattended system, and since CRON
  1119.         cannot know whether or not a spawned command has put the system into an
  1120.         unstable state, we cannot be quite sure that a 'disk full' error really
  1121.         means that the disk is full. To prevent disaster we simply let the
  1122.         standard DOS error handling take over, suspending everything until a
  1123.         human can take over. This is also known as the 'better safe than sorry'
  1124.         strategy.
  1125.  
  1126.         CRON relies on the fact that a spawned command will eventually return.
  1127.         If the command decides it wants keyboard input, and no one is around,
  1128.         CRON will be suspended until someone comes around to hit the keyboard.
  1129.         The net effect of a critical error hitting a spawned command is the
  1130.         same.
  1131.  
  1132.         The bottom line is that you should make sure no critical errors will
  1133.         occur when leaving CRON in charge of an unattended system.
  1134.         Specifically, make sure that all required peripherals are online, that
  1135.         any addressed printers are online and have enough paper, et cetera, et
  1136.         cetera. Also, make sure that spawned commands are started in such a way
  1137.         that they won't ever require keyboard input.
  1138.  
  1139.         Perhaps one day I'll understand what is so critical about a printer
  1140.         being out of paper, and why that condition is handled in the same way
  1141.         as a hard disk CRC error. Or perhaps I won't.
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1154.  
  1155.  
  1156.  
  1157.  
  1158.         CRON User's Guide            Rev. 10-21-90                      Page 16
  1159.  
  1160.  
  1161.         6.2 Failure to Spawn a Command
  1162.  
  1163.         CRON may fail trying to spawn a command. This is reflected by a log
  1164.         entry of the '<' or '<<' variety, with 'rc = -1'. If swapping is not
  1165.         enabled, an additional 'errno = n' is appended to the entry. See
  1166.         chapter 8 for interpretation of errno values.
  1167.  
  1168.         If swapping is enabled, 'rc = -1' always means that CRON could not
  1169.         locate the executable file. This may be caused by:
  1170.  
  1171.           -    you forgot to prefix a COMMAND.COM internal command with '!'
  1172.           -    the command does not exist in the current directory, nor in any
  1173.                directory in the current PATH.
  1174.  
  1175.         If a command name is given without an extension, CRON will try .COM,
  1176.         .EXE and .BAT exactly like COMMAND.COM does.
  1177.  
  1178.         If a '!' style command returns an exit code of -1, it means that the
  1179.         command interpreter itself failed to load. This is normally a serious
  1180.         condition, with possible causes:
  1181.  
  1182.           -    the command named by COMSPEC has disappeared or is no longer in
  1183.                the DOS PATH
  1184.           -    the COMSPEC environment variable has been corrupted
  1185.           -    the PATH environment variable has been corrupted
  1186.  
  1187.         If swapping is not enabled, 'errno' contains further information. If
  1188.         swapping is enabled, one of the three causes above apply.
  1189.  
  1190.  
  1191.  
  1192.         6.3 A Spawned Command Fails
  1193.  
  1194.         This is indicated by an exit code in the range 0..255. It means that
  1195.         CRON could spawn the command, and that the command itself returned a
  1196.         non-0 exit code when issuing the DOS TERMINATE call.
  1197.  
  1198.         CRON's actions depend on whether or not the current entry contains
  1199.         multiple commands.
  1200.  
  1201.         If the command was the only command in the CRONTAB entry, CRON simply
  1202.         records the exit code in the log (if enabled) and proceeds to schedule
  1203.         the next command. The philosophy behind this is that a failure in one
  1204.         crontab entry should not influence the operation of other, possible
  1205.         unrelated, crontab entries.
  1206.  
  1207.         If the command was part of a multi-command entry, CRON assumes that all
  1208.         commands in the entry are somewhat interdependent and therefore aborts
  1209.         execution of remaining commands in the entry, logging this fact if
  1210.         logging is enabled.
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1218.  
  1219.  
  1220.  
  1221.  
  1222.         CRON User's Guide            Rev. 10-21-90                      Page 17
  1223.  
  1224.  
  1225.         The CDD.EXE utility (documented in a later chapter) is a more
  1226.         intelligent alternative to COMMAND.COM's builtin CHDIR command. The
  1227.         crontab entry
  1228.  
  1229.           38 04 * * * ~cdd d:\acct\dbase;misreport
  1230.  
  1231.         will first change the logged drive and directory to 'D:\ACCT\DBASE',
  1232.         without swapping CRON, and then execute the command 'misreport'.
  1233.         Since 'misreport' obviously wants to be run from this drive/directory,
  1234.         we had better not run it if the 'cdd' command fails. So, if cdd returns
  1235.         a non-0 exit code, 'misreport' is skipped and CRON proceeds to schedule
  1236.         the next entry after logging the failure.
  1237.  
  1238.  
  1239.  
  1240.         6.4 Other Internal CRON errors
  1241.  
  1242.         If a swap file error occurs, CRON will report an error code of 256 (rc
  1243.         = 256) for the appropriate '<' or '<<' entry and will disable swapping
  1244.         for all commands thereafter. This may cause failure of other commands
  1245.         that need so much memory that they cannot coexist with CRON in memory.
  1246.  
  1247.         Error codes starting from 768 and upwards are specific to the swapping
  1248.         interface to the EXEC function, and are documented later.
  1249.  
  1250.  
  1251.  
  1252.         6.5 Exit Codes and COMMAND.COM
  1253.  
  1254.         COMMAND.COM is too dumb to return the exit code of a command that it
  1255.         spawns, even with the /C switch.
  1256.  
  1257.         Thus, when CRON executes a '!' entry or a .BAT file, it will receive an
  1258.         exit code 0 provided COMMAND.COM itself could be spawned, but the exit
  1259.         code from the actual command is lost even if it was non-0.
  1260.  
  1261.         Thus the following crontab entry may give surprising results:
  1262.  
  1263.         12 7 * * * !z:;!cd \absent;!XXXXXXXXXXXXX
  1264.  
  1265.         CRON will happily spawn all three commands, since spawning COMMAND.COM
  1266.         succeeds. COMMAND.COM will print something like 'Bad command or file
  1267.         name', but will still return an exit code of 0.
  1268.  
  1269.         Thus all three commands -- which failed -- show up with 'rc = 0' in the
  1270.         cronlog, since COMMAND.COM lies about the results.
  1271.  
  1272.         4DOS or some other more intelligent shell may handle this in a better
  1273.         way. For multi-command entries where changing drive and path is
  1274.         crucial, use the supplied CDD.EXE utility instead of "!d:;!cd \path"
  1275.         constructs.
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1282.  
  1283.  
  1284.  
  1285.  
  1286.         CRON User's Guide            Rev. 10-21-90                      Page 18
  1287.  
  1288.  
  1289.         7 ADVANCED TOPICS
  1290.  
  1291.  
  1292.  
  1293.         7.1 Resource Requirements
  1294.  
  1295.         CRON requires 44 KB of memory, plus up to 1K per 16 crontab entries.
  1296.         The number of crontab entries should be rounded up to the nearest
  1297.         multiple of 16. This is a worst-case estimate; most CRONTAB entries
  1298.         require less than 64 bytes.
  1299.  
  1300.         When swapping, CRON leaves 1.1K of itself -- plus the size of its
  1301.         environment -- in memory, swapping out the rest.
  1302.  
  1303.         When swapping to disk, CRON therefore needs (size of resident CRON -
  1304.         1.1K + pad to cluster boundary + directory overhead) bytes of disk
  1305.         space, typically less than 64K bytes.
  1306.  
  1307.         When swapping to EMS, CRON requires (size of resident CRON - 1.1K + pad
  1308.         to nearest 16K boundary) bytes, typically 3 pages = 48K bytes.
  1309.  
  1310.         For very large CRONTABS (several hundred entries) CRON may require 4
  1311.         EMS pages, i.e. 64K bytes.
  1312.  
  1313.         When swapping to disk, CRON uses 1 file handle which is left often
  1314.         across the EXEC call, reducing the spawned command's handle space from
  1315.         20 to 19.
  1316.  
  1317.         Similarly, when swapping to EMS, CRON uses 1 EMS handle which is kept
  1318.         across the EXEC call.
  1319.  
  1320.         CRON only needs EMS and disk space when a spawned command is actually
  1321.         executing. Between commands (i.e. when CRON is waiting for the next
  1322.         command to execute), no EMS or disk space is used.
  1323.  
  1324.         CRON hooks no interrupt vectors except those hooked by the run-time
  1325.         library, and does not use floating point.
  1326.  
  1327.  
  1328.  
  1329.         7.2 Using CRON with DESQview
  1330.  
  1331.         CRON works very well with DESQview. If you use DESQview, chances are
  1332.         that you have EMS in your system. If so, use the -s -e options to CRON
  1333.         for best results.
  1334.  
  1335.         CRON detects DESQview at startup. When executing its idle loop (i.e.
  1336.         waiting to execute the next command), CRON issues the 'give up time
  1337.         slice' DESQview API call. (In command line operation, CRON issues Int
  1338.         28H calls instead).
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1346.  
  1347.  
  1348.  
  1349.  
  1350.         CRON User's Guide            Rev. 10-21-90                      Page 19
  1351.  
  1352.  
  1353.         CRON is generally well behaved: all output is via DOS, input is via
  1354.         BIOS keyboard calls. Does not use floating point, can (should!) run in
  1355.         the background, does not use serial lines, does not require a floppy
  1356.         disk.
  1357.  
  1358.         Note that CRON should not be swapped out by DESQview, because of its
  1359.         real-time nature. Having DESQview swap CRON would invalidate CRON's
  1360.         timing function.
  1361.  
  1362.         So, when designing a DESQview profile for CRON, you should think more
  1363.         about the programs you are spawning from CRON than about CRON itself.
  1364.  
  1365.         For example, if you spawn a telecommunications program (which is a
  1366.         natural for CRON), you should tell DESQview about which port it uses.
  1367.         Also, if a spawned program needs EMS memory, the amount should be ADDED
  1368.         to amount required by CRON if CRON is swapping to EMS.
  1369.  
  1370.         The previous subsection states the memory resources needed by CRON in
  1371.         its different operational modes. These should be added to whatever is
  1372.         required by spawned programs.
  1373.  
  1374.  
  1375.  
  1376.         7.3 CRON Technical Information
  1377.  
  1378.         CRON is written in C and assembler and compiled with Turbo C++ (ANSI C
  1379.         compiler mode) and TASM 2.0.
  1380.  
  1381.         The Compact memory model is used, allowing an unlimited CRONTAB size
  1382.         subject to memory constraints. Because of the way Turbo C sets up
  1383.         DGROUP, CRON actually uses LESS memory in the Compact model than in the
  1384.         Small model, for crontabs up to 2-300 entries.
  1385.  
  1386.         The CRON source code is around 2500 lines, including comments.
  1387.  
  1388.         CRON uses only documented DOS and BIOS calls. All EMS access is via
  1389.         interrupt 67H, using the approved methods to detect the presence of an
  1390.         EMS manager.
  1391.  
  1392.  
  1393.  
  1394.         7.4 Differences between CRON and UNIX cron
  1395.  
  1396.         There are two major differences between CRON and UNIX cron:
  1397.  
  1398.           -    UNIX cron runs in the background
  1399.           -    UNIX cron executes commands concurrently, while CRON executes
  1400.                commands sequentially.
  1401.  
  1402.         Under UNIX, two commands can be started by cron at the same time (well,
  1403.         almost). Under DOS, two commands scheduled to execute at the same time
  1404.         will execute one after the other, and the order of execution is random.
  1405.  
  1406.  
  1407.  
  1408.  
  1409.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1410.  
  1411.  
  1412.  
  1413.  
  1414.         CRON User's Guide            Rev. 10-21-90                      Page 20
  1415.  
  1416.  
  1417.         Since UNIX cron runs in the background, and concurrently with the
  1418.         commands it spawns, a spawned command can never suspend cron. As
  1419.         described above, this may well happen with CRON in some cases.
  1420.  
  1421.         The background nature of UNIX cron can be emulated to some extent by
  1422.         running CRON under DESQview. Concurrency it not possible, however.
  1423.  
  1424.         With CRON, a command can be delayed if the previous command executes
  1425.         for a long time, i.e. past the time that the next command was due to
  1426.         execute. All commands will be executed, though. UNIX cron always starts
  1427.         commands at the scheduled times.
  1428.  
  1429.         Some of the more esoteric fields of the UNIX cronlog have been skipped,
  1430.         such as PID's of commands.
  1431.  
  1432.         The UNIX 'crontab' utility is of limited use under DOS and is not
  1433.         implemented.
  1434.  
  1435.         The LOGCHECK.EXE utility performs about the same actions as the UNIX
  1436.         /etc/logchecker shell script.
  1437.  
  1438.         UNIX cron reads all files in the /usr/spool/cron/crontabs directory as
  1439.         crontabs when it starts up -- this is the central repository of all
  1440.         user's crontabs. Since DOS's multiuser capability is somewhat limited,
  1441.         this feature was not deemed necessary. Also, hard-coded directory names
  1442.         and excessive use of environment variables are not popular in DOS
  1443.         circles.
  1444.  
  1445.         UNIX cron writes its logfile in the /usr/lib/cron directory. CRON's
  1446.         logfile is defined by the CRONLOG environment variable.
  1447.  
  1448.         UNIX cron re-reads its crontabs at run time if a crontab is modified by
  1449.         the 'crontab' utility.
  1450.  
  1451.         With CRON, you stop CRON, modify the crontab and restart CRON to
  1452.         achieve the same effect.
  1453.  
  1454.         The command-line options to CRON are not available nor useful under
  1455.         UNIX.
  1456.  
  1457.         The '~' and '!' command prefixes are specific to CRON and are not
  1458.         available (nor meaningful) with UNIX cron.
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1474.  
  1475.  
  1476.  
  1477.  
  1478.         CRON User's Guide            Rev. 10-21-90                      Page 21
  1479.  
  1480.  
  1481.         8 REFERENCE SECTION
  1482.  
  1483.  
  1484.  
  1485.         8.1 Error Messages
  1486.  
  1487.         CRON can complain about various things, at startup and later. All error
  1488.         output is sent to stdout (i.e. DOS handle 2). Any startup error, and
  1489.         some other errors, make CRON terminate.
  1490.  
  1491.         The following list describes the errors (in no particular order):
  1492.  
  1493.  
  1494.         cdd("dirname") failed
  1495.                CRON failed to do an internal drive/directory change. Usually
  1496.                means disk failure, or a spawned command has wreaked havoc in
  1497.                your system. This error can occur after each spawned command.
  1498.  
  1499.  
  1500.         No memory for crontab
  1501.                CRON failed to allocate dynamic memory for loading the crontab.
  1502.                This means that your crontab is *very* large or that you have
  1503.                very little memory in your system.
  1504.  
  1505.  
  1506.         'command' : illegal date
  1507.                The crontab entry containing 'command' specifies an illegal
  1508.                date, for example February 31. Correct the crontab entry.
  1509.  
  1510.  
  1511.         Syntax: 'entry'
  1512.                The crontab line containing 'entry' does not conform to crontab
  1513.                entry syntax rules. Correct the offending line.
  1514.  
  1515.  
  1516.         CRONTAB is empty
  1517.                No entries were found in crontab.
  1518.  
  1519.  
  1520.         'file': cannot open
  1521.                CRON could not open the named file. File probably does not
  1522.                exist.
  1523.  
  1524.  
  1525.         'name': not a directory
  1526.                The specified 'name' is not a directory (swap mode).
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1538.  
  1539.  
  1540.  
  1541.  
  1542.         CRON User's Guide            Rev. 10-21-90                      Page 22
  1543.  
  1544.  
  1545.         Unable to locate CRONTAB
  1546.                Either the file name pointed to by the CRONTAB environment
  1547.                variable is invalid, or the file "CRONTAB" was not found in the
  1548.                startup directory.
  1549.  
  1550.  
  1551.         'CRONLOG=name' : not fully qualified
  1552.                The environment variable CRONLOG contains a name that is not a
  1553.                fully qualified filename.
  1554.  
  1555.  
  1556.         'CRONLOG=name' : cannot open
  1557.                CRON was unable to open the file named by the CRONLOG
  1558.                environment variable. Either the file exists and is read-only,
  1559.                or the name specifies a directory, or the network denied create
  1560.                or write access to the file.
  1561.  
  1562.  
  1563.         (DESQview detected)
  1564.                Not an error message, but a startup message stating that CRON
  1565.                believes that it is running under DESQview.
  1566.  
  1567.  
  1568.  
  1569.         8.2 Exit Codes
  1570.  
  1571.         Some exit codes (shown in the cronlog as 'rc = nn') have slightly
  1572.         different interpretations when running CRON in swap or non-swap mode.
  1573.  
  1574.  
  1575.  
  1576.         8.2.1 Common Exit Codes
  1577.  
  1578.         All exit codes in the range 0..255 are actual exit codes from spawned
  1579.         commands. Their interpretation is specific to each actual command. CRON
  1580.         does not attempt to interpret these codes except that in a multi-
  1581.         command entry, the remaining commands in the entry will be skipped if a
  1582.         command returns a non-0 exit code, as explained earlier.
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1602.  
  1603.  
  1604.  
  1605.  
  1606.         CRON User's Guide            Rev. 10-21-90                      Page 23
  1607.  
  1608.  
  1609.         8.2.2 Swap Mode
  1610.  
  1611.         In swap mode, interpret exit codes as follows:
  1612.  
  1613.           -1        named command not found. Either the command is actually
  1614.                     non-existent, or you forgot to prefix a COMMAND.COM
  1615.                     internal command with '!'
  1616.  
  1617.           0..255    see 8.2.1
  1618.  
  1619.           256       swap file error. CRON switches swapping off permanently and
  1620.                     continues execution.
  1621.  
  1622.           770       DOS EXEC: file not found
  1623.           771       DOS EXEC: path not found
  1624.           772       DOS EXEC: too many open files
  1625.           773       DOS EXEC: access denied
  1626.           776       DOS EXEC: not enough memory to load command
  1627.           778       DOS EXEC: environment is corrupt
  1628.           779       DOS EXEC: bad format for .EXE file (.EXE file is corrupt)
  1629.  
  1630.  
  1631.  
  1632.         8.2.3 Non-Swap Mode
  1633.  
  1634.         In non-swap mode, interpret exit codes as follows:
  1635.  
  1636.           -1        spawn failure, errno gives further information
  1637.  
  1638.           0..255    see 8.2.1
  1639.  
  1640.         For -1, errno can take one of the following values:
  1641.  
  1642.            2        ENOENT:  path or file not found
  1643.            8        ENOMEM:  not enough memory to spawn command
  1644.           19        EINVAL:  illegal argument
  1645.           20        E2BIG:   argument list is too long
  1646.           21        ENOEXEC: .EXE file format error
  1647.  
  1648.  
  1649.  
  1650.         8.2.4 RC = -1 for '!' Commands
  1651.  
  1652.         If a command prefixed with '!' returns with 'rc = -1', it means that
  1653.         CRON was unable to spawn the command interpreter, i.e. the program
  1654.         named by the COMSPEC environment variable.
  1655.  
  1656.         This is a serious error. Some possible causes are:
  1657.  
  1658.           -    the COMSPEC environment variable has been corrupted
  1659.           -    the PATH has been corrupted
  1660.           -    the program named by COMSPEC (e.g. C:\COMMAND.COM) has
  1661.                disappeared. Look out for viruses.
  1662.           -    not enough memory to spawn command interpreter.
  1663.  
  1664.  
  1665.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1666.  
  1667.  
  1668.  
  1669.  
  1670.         CRON User's Guide            Rev. 10-21-90                      Page 24
  1671.  
  1672.  
  1673.         9 UTILITY PROGRAMS
  1674.  
  1675.  
  1676.  
  1677.         9.1 CDD.EXE
  1678.  
  1679.         CDD (for "change drive and directory") is a smarter replacement for
  1680.         DOS's CHDIR (CD) command. Since CDD is an .EXE file, it will return an
  1681.         exit code != 0 if it was unable to switch drive and/or directory.
  1682.  
  1683.         USE: cdd [d:][\path]
  1684.  
  1685.         Exit codes:
  1686.  
  1687.           0    -- success
  1688.           1    -- could not switch drive
  1689.           2    -- could not change directory
  1690.           3    -- bad command line syntax
  1691.  
  1692.         CDD is small, so I recommend using the '~' command prefix when using
  1693.         CDD in crontabs.
  1694.  
  1695.         Typing "CDD ?" gives a command syntax reminder.
  1696.  
  1697.  
  1698.  
  1699.         9.2 LOGCHECK.EXE
  1700.  
  1701.         CRON usually produces large logfiles. To avoid excessive log sizes, put
  1702.         a call to LOGCHECK in your crontab, with a period depending on how much
  1703.         you use CRON and the execution frequency of your crontab entries.
  1704.  
  1705.         USE: logcheck [-s maxsize] [-L]
  1706.  
  1707.         where 'maxsize' is the decimal number of kilobytes that you want your
  1708.         logfile not to exceed. If no 'maxsize' is entered, LOGCHECK assumes a
  1709.         value of 32. Use -L if you want LOGCHECK to lock the logfile when it
  1710.         operates (similar to CRON's -L option).
  1711.  
  1712.         If LOGCHECK finds that your current cronlog exceeds 'maxsize' it will
  1713.         perform the following actions:
  1714.  
  1715.           --   copy the current cronlog to a file with the same name but with
  1716.                extension 'old'. For example, if your cronlog is named
  1717.                'CRONLOG.CUR', its current contents will be copied to
  1718.                'CRONLOG.OLD'. If your cronlog is named 'CRONLOG.OLD', the copy
  1719.                will be named 'CRONLOG.OL2'. Any existing file with the modified
  1720.                name will be destroyed. The copy is made in the same directory
  1721.                as the cronlog.
  1722.  
  1723.           --   truncate the cronlog to 0 size, then add the following entry:
  1724.                '!logswap <timestamp>'.
  1725.  
  1726.  
  1727.  
  1728.  
  1729.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1730.  
  1731.  
  1732.  
  1733.  
  1734.         CRON User's Guide            Rev. 10-21-90                      Page 25
  1735.  
  1736.  
  1737.         The following crontab entry will check your network cronlog daily,
  1738.         making sure it doesn't become much larger than 64K:
  1739.  
  1740.         13 5 * * * ~logcheck -s 64 -L
  1741.  
  1742.  
  1743.         Exit codes from LOGCHECK:
  1744.  
  1745.           0    -- successful log swap
  1746.           1    -- no action (log smaller than maxsize)
  1747.           2    -- could not swap log (disk error, access denied)
  1748.           3    -- CRONLOG environment variable not found.
  1749.           4    -- bad command line syntax
  1750.  
  1751.  
  1752.         Typing "LOGCHECK ?" gives a command syntax reminder.
  1753.  
  1754.         Caveat: LOGCHECK can only check the log when it is activated. Thus
  1755.         between invocations, the log can grow to a size much larger than
  1756.         'maxsize' if there is a lot of CRON activity going on. Select LOGCHECK 
  1757.         periodicity according to your crontab.
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1794.  
  1795.  
  1796.  
  1797.  
  1798.         CRON User's Guide            Rev. 10-21-90                      Page 26
  1799.  
  1800.  
  1801.         10PROGRAM HISTORY
  1802.  
  1803.  
  1804.  
  1805.         Version     Date      Comments
  1806.         -----------------------------------------------------------------------
  1807.         0.0 - 1.0   10-19-90  Internal versions
  1808.         1.1         10-20-90  First public release
  1809.         1.2         10-21-90  Benign bug fixed: in the absence of the -L
  1810.                               option, a file handle was needlessly kept open
  1811.                               permanently. Harmless, but wasteful. Also,
  1812.                               CRON.DOC stated that CRON would swap to the
  1813.                               current directory if no TMP variable and if no -d
  1814.                               option. This is wrong. CRON will swap to the
  1815.                               directory that was current when CRON started
  1816.                               under these conditions. LOGCHECK.EXE always
  1817.                               unlocked the logfile even if locking was not
  1818.                               specified.
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.         CRON User's Guide            Rev. 10-21-90        (C) 1990 Tron Hvaring
  1858.